<template>
  <div class="hello">
    <h1>{{msg}}</h1>
    <el-row>
      <el-button @click="submitForm">默认按钮</el-button>
      <el-button type="primary">主要按钮</el-button>
      <el-button type="success">成功按钮</el-button>
      <el-button type="info">信息按钮</el-button>
      <el-button type="warning">警告按钮</el-button>
      <el-button type="danger">危险按钮</el-button>
    </el-row>
  </div>
</template>
<script>
import { filterEmoticon } from '../common/helpers'

export default {
  components: {
    filterEmoticon
  },
  name: 'Test',
  data () {
    return {
      msg: filterEmoticon(
        '@管理员:dgdgogngngngngdgmdgfmgngngmgogmgmgng [鄙视1][鄙视][鄙视][鄙视][哈欠][哈欠][哈欠][哈欠][哈欠]#话题# dgmgmgngmgmgmgmgngngmgm[鄙视][鄙视][鄙视][鄙视][鄙视]'
      )
    }
  },
  methods: {
    submitForm () {
      this.axios
        .get('/site/index')
        .then(response => {
          this.msg = response.data.msg
        })
        .catch(function (error) {
          console.log(error)
        })
    },
    emoji () {
      // 完整的qq表情见本文末尾
      var face = {
        '[大笑]': '<img src="images/face/daxiao.gif" alt="" />',
        '[哭]': '<img src="images/face/ku.gif" alt="" />',
        '[哈欠]': '<img src="images/face/haha.gif" alt="" />',
        '[鄙视]': '<img src="images/face/bisi.gif" alt="" />',
        '[流汗]': '<img src="images/face/liuhan.gif" alt="" />'
      }

      var reg = /\[.+?\]/g

      // 这里是获取到的文本域的value，简洁起见，直接使用了字符串。
      let str =
        '@管理员:dgdgogngngngngdgmdgfmgngngmgogmgmgng [鄙视1][鄙视][鄙视][鄙视][哈欠][哈欠][哈欠][哈欠][哈欠]#话题# dgmgmgngmgmgmgmgngngmgm[鄙视][鄙视][鄙视][鄙视][鄙视]'

      str = str.replace(reg, function (a, b) {
        return face[a] ? face[a] : a
      })

      console.log(str)
      return str
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
  color: #000;
  font-size: 0.4rem;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
